package com.example.back.controller;

import com.example.back.entity.Comment;
import com.example.back.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;

@RestController
public class CommentController {
    @Autowired
    private CommentService commentService;
    @PostMapping("/comment")
    public int addComment(@RequestBody Comment comment){
        return commentService.addComment(comment);
    }
    @DeleteMapping("/comment/{id}")
    public int deleteComment(@PathVariable("id") Integer id){
        return commentService.deleteComment(id);
    }
    @PutMapping("/comment")
    public int updateComment(@RequestBody Comment comment){
        return commentService.updateComment(comment);
    }
    @GetMapping("/comment/{id}")
    public Comment queryCommentById(@PathVariable("id") Integer id){
        return commentService.queryCommentById(id);
    }
    @GetMapping("/comment")
    public ArrayList<Comment> queryComments(@RequestBody Comment comment){
        return commentService.queryComments(comment);
    }
}
